<?php
class Mysql extends PDO
{
	function __construct($dbhost, $dbuser, $dbpw, $dbname, $dbcharset, $tablepre='') 
	{
		$dsn = 'mysql:dbname='.$dbname.';host='.$dbhost;
		try {
		    $this->dbh = new PDO($dsn, $dbuser, $dbpw);
		} catch (PDOException $e) {
		    echo 'Connection failed: ' . $e->getMessage();
		    exit;
		}
	}
	
	function fetchAll($sql)
	{
		$sth = $this->dbh->prepare($sql);
		$sth->execute();
		return $sth->fetchAll(PDO::FETCH_ASSOC);
	}
	
	function fetchRow($sql)
	{
		$sth = $this->dbh->prepare($sql);
		$sth->execute();
		return $sth->fetch(PDO::FETCH_ASSOC);	
	}
	
	function fetchFirst($sql)
	{
		$sth = $this->dbh->prepare($sql);
		$sth->execute();
		$result = $sth->fetch(PDO::FETCH_NUM);
		return $result[0];
	}
	
	function version() {
		return mysql_get_server_info();
	}
	
}

?>